﻿//----------------------------------------------------------------
// Desc: 
// Edit: ShowLong, http://blog.csdn.net/showlong
//
// Date Created: 2012-04-13
//
// Update Date : 
//
// Copyright (c) Fuel4D (http://www.fuel4d.com), All rights reserved.
//
//----------------------------------------------------------------
#pragma once


class IFRefObject : public IFMemObject
{
protected:
    explicit IFRefObject()
        :nRefCount(0)
    {}

public:
    // 增加引用计数
    FINLINE LONG AddRef()
    {
        FInterlockedIncrement(&nRefCount);
        return nRefCount;
    }
    // 释放引用计数
    FINLINE LONG DecRef()
    {
        FInterlockedDecrement(&nRefCount);
        return nRefCount;
    }
    // 获取引用计数
    FINLINE LONG GetRefCount()
    {
        return nRefCount;
    }

protected:
    FVOLATILE LONG nRefCount;        // 引用计数
};